package org.primefaces.examples.moviecollector.dao;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.primefaces.examples.moviecollector.domain.Calificacion;
import org.springframework.stereotype.Repository;


@Repository
public class CalificacionDAOWithJPA implements CalificacionDAO {
	
@PersistenceContext	
protected EntityManager entityManager;
	
	
	public EntityManager getEntityManager() {
		return entityManager;
	}

	public void setEntityManager(EntityManager entityManager) {
		this.entityManager = entityManager;
	}



	public void persist(Calificacion calif) {
		entityManager.persist(calif);
		
	}

	public void update(Calificacion calif) {
		entityManager.merge(calif);
		
	}

	public void delete(Calificacion calif) {
		entityManager.createQuery("DELETE FROM Calificacion u WHERE u.id=:id").setParameter("id", calif.getId()).executeUpdate();
	}

	

	
}
